import Vue from 'vue'
import Router from 'vue-router'
import myLogin from "@/components/myLogin"
const myHome = () => import("@/components/myHome")
const myTable = () => import("@/components/myTable")
const newPaper = () => import("@/components/newPaper")
const myExport = () => import("@/components/myExport")
const newPatent = () => import("@/components/newPatent")
const newProject = () => import("@/components/newProject")
const newAwarded = () => import("@/components/newAwarded")

Vue.use(Router)
// 重复点击导航出错
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
}

export default new Router({
  routes: [
    {
      path: '/', component: myLogin, name: 'login'
    },
    {
      path: '/home', component: myHome, children: [{
        path: '', component: myTable, name: 'table'
      },
      {
        path: 'paper', component: newPaper, name: 'paper'
      },
      {
        path: 'export', component: myExport, name: 'export'
      },
      {
        path: 'patent', component: newPatent, name: 'patent'
      },
      {
        path: 'project', component: newProject, name: 'project'
      },
      {
        path: 'awarded', component: newAwarded, name: 'awarded'
      }]
    }
  ]
})
